﻿historical_figure_initialize_all_effect = {

	random_living_character = {
		historical_figure_birth_check_existence_all_effect = yes
		if = {
			limit = {
				NAND = {
					current_month = 1
					current_day   = 1
				}
			}
			historical_figure_check_change_first_name_all_effect = yes
		}
	}

}


historical_figure_initialize_effect = {

	character:$CHAR$ = {
		save_scope_value_as = {
			name = desc
			value = $DESC$
		}
		if = {
			limit = {
				is_alive = yes
			}
			set_variable = {
				name = historical_figure_id
				value = $FIGURE$
			}
			add_to_global_variable_list = {
				name = historical_figure_list
				target = this
			}
		}
		if = {
			limit = {
				scope:desc = 1
			}
			add_trait = historical_character
			set_variable = {
				name = show_historical_gui
				value = 1
			}
		}
	}

}


historical_figure_change_first_name_effect = {

	every_in_global_list = {
		variable = historical_figure_list
		limit = {
			var:historical_figure_id = $FIGURE$
		}
		random_province = {
			save_scope_as = birthplace
		}
		create_character = {
			name = $NAME$
			culture = root.culture
			faith = root.faith
			gender = male
			location = scope:birthplace
			save_scope_as = historical_figure_change_first_name_character
		}
		change_first_name = { template_character = scope:historical_figure_change_first_name_character }
		scope:historical_figure_change_first_name_character = {
			death = { death_reason = death_vanished }
		}
	}

}


historical_figure_on_death_effect = {

	if = {
		limit = {
			exists = var:historical_figure_id
		}
		remove_list_global_variable = {
			name = historical_figure_list
			target = root
		}
	}

}
